<?php
include("../Core/Common.php");
error_reporting(0);

session_start();
header('Content-type: application/json');

$act=isset($_GET['do'])?daddslashes($_GET['do']):null;

switch($act){
case 'getyzm':
	$email=daddslashes($_GET['qq'].'@qq.com');	
	$qq = str_replace("@qq.com","",$email);
	$riw = $DB->query("SELECT * FROM pay_check WHERE qq='{$qq}' limit 1")->fetch();
    if(!$riw){
	exit('{"code":-1,"msg":"此QQ未查询到是已授权的QQ,禁止获取！"}');	   	
	}	
	$sub = ''.$conf['sitename'].' - 源码下载申请验证码';
	$code = rand(1111,9999);
	$_SESSION['check_qq'] = $qq;
	$_SESSION['check_code'] = $code;
	$_SESSION['check_time'] = (time()+180);
	$msg = '您的验证码是：'.$code;		
	send_mail($email,$sub, $msg);
	exit('{"code":0,"msg":"发送成功'.$email.'"}');
break;
case 'checkyzm':
	$qq=daddslashes($_GET['qq']);
	$yzm=daddslashes($_GET['yzm']);
	$riw = $DB->query("SELECT * FROM pay_check WHERE qq='{$qq}' limit 1")->fetch();
	if($_SESSION['check_code']==$yzm and $_SESSION['check_qq']==$qq)
	{
	exit('{"code":0,"msg":"验证成功","backurl":"index.php?qq='.$qq.'&url='.$riw['url'].'"}');
	}else{
	exit('{"code":-1,"msg":"验证码错误,确保验证码准确,否则无法下载源码！'.$yzm.'"}');		
	}
break;
default:
	exit('{"code":-4,"msg":"No Act"}');
break;
}